package com.mapDemo.hashMap;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Author milian
 * @Date 2021/7/26 0026 17:57
 */
public class demo1 {
    public static void main(String[] args) {
        HashMap<String, String> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("itheima001","林青霞");
        stringStringHashMap.put("itheima002","张曼玉");
        stringStringHashMap.put("itheima003","王祖贤");
        stringStringHashMap.put("itheima003","柳岩");
        stringStringHashMap.remove("itheima001");
        boolean b = stringStringHashMap.containsKey("itheima002");
        boolean b1 = stringStringHashMap.containsValue("张曼玉");
        boolean b3 = stringStringHashMap.isEmpty();
        System.out.println(b);
        System.out.println(b1);
        System.out.println(b3);
        System.out.println(stringStringHashMap);
//        遍历hashmap集合
        Set<String> key = stringStringHashMap.keySet();
        Collection<String> values = stringStringHashMap.values();
        Set<Map.Entry<String, String>> entries = stringStringHashMap.entrySet();
        for (String k: key
             ) {
            System.out.println(k+","+stringStringHashMap.get(k));
        }
        for (String k: values
             ) {
            System.out.println(k);
        }
        for (Map.Entry<String,String> me: entries
             ) {
            System.out.println(me.getKey()+","+me.getValue());
        }
    }
}
